package com.me.Inheritor;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;

public class Player extends ControllerObject
{
	Vector2		velocity;
	float		gravity;
	float		jumpIntensity;
	
	public Player()
	{
		setTexture( GameData.getTextureManager().LoadTexture( "data/player.png") );
		
		Texture texture = GameData.getTextureManager().getTexture(getTexture());
		
		width = texture.getWidth();
		height = texture.getHeight();
		
		velocity = new Vector2( 0,0 );
		gravity = 1500;
		jumpIntensity = 700;
		
		position.x = Gdx.graphics.getWidth()/2 - width;
		
		width = 64;
		height = 64;
	}

	public void Input()
	{
		if( Gdx.input.justTouched() && velocity.y == 0 )
			velocity.y += jumpIntensity;
	}
	
	public void Update( float dt )
	{
		Input();
		
		prevPosition.x = position.x;
		prevPosition.y = position.y;
		
		// Apply gravity
		velocity.y -= gravity*dt;
		
		// Apply velocity
		position.x += velocity.x * dt;
		position.y += velocity.y * dt;
		
		// Make sure the player doesn't go off the screen
		if( position.y < 0 )
		{
			position.y = 0;
			velocity.y = 0;
		}
	}
	
	public Vector2 getVelocity()
	{
		return velocity;
	}
	public float getXVelocity()
	{
		return velocity.x;
	}
	public float getYVelocity()
	{
		return velocity.y;
	}
	public void setVelocity( Vector2 vel )
	{
		velocity.x = vel.x;
		velocity.y = vel.y;
	}
	public void setXVelocity( float x )
	{
		velocity.x = x;
	}
	public void setYVelocity( float y )
	{
		velocity.y = y;
	}
}
